﻿<UserControl x:Class="CCCBrowser.CCCBrowserControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="clr-namespace:CCCBrowser"
     xmlns:theming="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.Toolkit"
  xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
  Loaded="UserControl_Loaded"
    >
    <UserControl.Resources>
        
        <ui:MajorConverter x:Key="MajorConverter" />
        <ui:AlignmentConverter x:Key="AlignmentConverter" />

        <SolidColorBrush x:Key="DiagnosisBackground" Color="Green" />
        <SolidColorBrush x:Key="InterventionBackground" Color="Blue" />
        <SolidColorBrush x:Key="ComponentBackground" Color="Pink" />

        <DataTemplate x:Key="detailsFrameworkElement">
            <Grid>
                <Border Margin="2" Padding="3"   
            CornerRadius="5"
             BorderThickness="1" 
             BorderBrush="Black" >
                    <!--<Button>
                <Button.Content>
                    <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">-->
                    <StackPanel>
                        <TextBlock x:Name="tbConcept" Text="{Binding Path=Concept}" FontWeight="Bold" TextWrapping="Wrap" />
                        <TextBlock x:Name="tbDefinition" Text="{Binding Path=Definition}" MaxWidth="200" TextWrapping="Wrap" />
                    </StackPanel>
                    <!--</ScrollViewer>
                </Button.Content>
            </Button>-->

                </Border>
            </Grid>

        </DataTemplate>

        <Style x:Key="HeaderTemplate" TargetType="TextBlock">
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="13" />
        </Style>
        
        <DataTemplate x:Key="componentHeader">
            <StackPanel Background="{StaticResource ComponentBackground}">
                <TextBlock Text="Components" FontWeight="Bold"   />
            </StackPanel>
        </DataTemplate>


        <DataTemplate x:Key="interventionHeader">
            <StackPanel Background="{StaticResource InterventionBackground}">
                <TextBlock Text="Interventions" FontWeight="Bold"   />
            </StackPanel>
        </DataTemplate>


        <DataTemplate x:Key="diagnosisHeader">
            <StackPanel Background="{StaticResource DiagnosisBackground}">
                <TextBlock Text="Diagnoses" FontWeight="Bold"  />
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="detailsOutcome">
                <TextBlock Text="{Binding Path=Concept}" ToolTipService.ToolTip="{Binding Path=Definition}" />
            </DataTemplate>
        
        <DataTemplate x:Key="detailsDiagnosis">
            <!--<Border Height="70"  Margin="2" Padding="3"   
            CornerRadius="5"
             BorderThickness="1" 
             BorderBrush="Black" >-->
            <!--<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" >-->
            <StackPanel>
                <TextBlock Text="{Binding Path=Concept}" FontWeight="Bold" TextWrapping="Wrap" />
                <TextBlock Text="{Binding Path=Definition}" MaxWidth="200" TextWrapping="Wrap" />

            </StackPanel>
            <!--</ScrollViewer>-->

            <!--</Border>-->

        </DataTemplate>

        <DataTemplate x:Key="detailsIntervention">
            <!--<Border Height="70"  Margin="2" Padding="3"   
            CornerRadius="5"
             BorderThickness="1" 
             BorderBrush="Black" >-->
            <!--<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" >-->
            <StackPanel HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=Concept}" FontWeight="Bold" TextWrapping="Wrap" />
                <TextBlock Text="{Binding Path=Definition}" MaxWidth="200" TextWrapping="Wrap" />
            </StackPanel>
            <!--</ScrollViewer>-->

            <!--</Border>-->

        </DataTemplate>
        </UserControl.Resources>
	
       
	    <ScrollViewer 
	    ScrollViewer.VerticalScrollBarVisibility="Auto"
        MaxWidth="250"
        >

        <StackPanel>



            <StackPanel x:Name="spMetaInformation"
                   >

                <TextBlock  
                         Text="{Binding Name}" 
                       TextWrapping="Wrap" MaxWidth="200" HorizontalAlignment="Left"
                        FontWeight="Bold" />

                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Version" FontSize="9" />

                    <TextBlock  
                       Margin="5,0,0,0" Text="{Binding Version}" 
                       TextWrapping="Wrap" 
                        FontSize="9" />

                </StackPanel>


                <TextBlock Text="{Binding Authors}" MaxWidth="200" TextWrapping="Wrap" 
                 FontSize="9" HorizontalAlignment="Left"/>
                <TextBlock Text="{Binding LastUpdateString}" FontSize="9" />

            </StackPanel>


            <ComboBox x:Name="cbLanguage" 
        SelectionChanged="cbLanguage_SelectionChanged"
        HorizontalAlignment="Left"
        VerticalAlignment="Top"
        Margin="0,3,0,0"
           >
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding ImageURL}" ToolTipService.ToolTip="{Binding FriendlyLanguage}"  Height="20" />
                            <TextBlock Margin="3,0,0,0" Text="{Binding Path=Version}" VerticalAlignment="Center" />
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <toolkit:Expander Header="Patterns" 
            IsExpanded="True"
            Margin="0,5,0,0"
   
    >

                <!-- Observation : ApplyMode OneTime - only styles root control and not children 
      ApplyMode Auto - children are also styled
    -->
                <Grid x:Name="LayoutRoot" 
          
    
    >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <Button x:Name="btnPattern1" Grid.Row="0"  Click="firePatternChanged" Margin="1"  />
                    <Button x:Name="btnPattern2" Grid.Row="1"  Click="firePatternChanged" Margin="1" />
                    <Button x:Name="btnPattern3" Grid.Row="2"  Click="firePatternChanged" Margin="1" />
                    <Button x:Name="btnPattern4" Grid.Row="3"  Click="firePatternChanged" Margin="1" />

                </Grid>

            </toolkit:Expander>

            <toolkit:Expander x:Name="exCareComponent" 
        HeaderTemplate="{StaticResource componentHeader}" 
        Expanded="exCareComponent_Expanded"
        Margin="0,5,0,0"
        
        >

                <StackPanel>
                    <ContentControl 
         x:Name="detailsCareComponent" 
        Grid.Row="1" 
        Visibility="Collapsed" 
        ContentTemplate="{StaticResource detailsFrameworkElement}"/>

                    <!--<StackPanel Orientation="Horizontal">
                        <Button  x:Name="btnFreeDiagnosis" Content="Create diagnosis" 
                ToolTipService.ToolTip="Adds a free form diagnosis (associated with component)"  Click="btnFreeDiagnosis_Click" />
                        <Button  x:Name="btnFreeIntervention" Content="Create intervention" 
                ToolTipService.ToolTip="Adds a free form intervention (associated with component)"  Click="btnFreeIntervention_Click" />
                    </StackPanel>-->



                    <ListBox Margin="2" 
                x:Name="lbCareComponents" 
                Grid.Row="2"
              
                SelectionChanged="lbCareComponents_SelectionChanged">
                        
                        <!--<ListBox.Background>
                        <StaticResource ResourceKey="ComponentBackgroundBrush"/>
                    </ListBox.Background>-->
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Concept}" ToolTipService.ToolTip="{Binding Path=Definition}" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                </StackPanel>
            </toolkit:Expander>


            <toolkit:Expander 
        
         x:Name="exIntervention" Header="Interventions"
          HeaderTemplate="{StaticResource interventionHeader}"         
          Expanded="exIntervention_Expanded"
          Margin="0,5,0,0"
        
          >
                
                    <StackPanel>

                    <Button x:Name="btnDetailsIntervention" 
                Click="btnDetailsIntervention_Click" 
        Visibility="Collapsed"  
        Grid.Row="1"
         ContentTemplate="{StaticResource detailsIntervention}"
       >

                    </Button>

                    <Grid Margin="0,3,0,3" x:Name="gridActionTypes" Visibility="Collapsed">
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="130"/>
                        </Grid.ColumnDefinitions>
                        
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock  Text="Select" FontWeight="Bold" Grid.Row="0" Grid.Column="0" />
                             
                        <ComboBox   Margin="2,0,0,2" Grid.Row="0" Grid.Column="1"
                                x:Name="cbActionTypes" 
                                SelectionChanged="cbActionTypes_SelectionChanged"
                                HorizontalAlignment="Left">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=Concept}"
                                     ToolTipService.ToolTip="{Binding Path=Definition}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>

                        <TextBlock Text="Synonym" FontWeight="Bold"  Grid.Row="1" Grid.Column="0" />
                        <input:AutoCompleteBox x:Name="acActionTypeSynonyms"
                        Grid.Row="1" Grid.Column="1" />
                   
                        <TextBlock Text="Attach" Grid.Row="2" Grid.Column="0" FontWeight="Bold" />

                        <CheckBox x:Name="chAttachActionType" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left"/>

                   
                    </Grid>




                    <ListBox x:Name="lbInterventions" 
        SelectionChanged="lbInterventions_SelectionChanged" >
                        <ListBox.Resources>
                            <LinearGradientBrush x:Key="DiagnosisBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FF000000" Offset="0"/>
                                <GradientStop Color="#FFCFCFFE" Offset="1"/>
                            </LinearGradientBrush>
                        </ListBox.Resources>
                        <!--<ListBox.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFCFCFFE" Offset="1"/>
                            <GradientStop Color="#FF7B7B7B" Offset="0.031"/>
                        </LinearGradientBrush>
                    </ListBox.Background>-->
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Path=Concept}" 
                                ToolTipService.ToolTip="{Binding Path=Definition}" 
                                FontWeight="{Binding Converter={StaticResource MajorConverter}}" 
                                Margin="{Binding Converter={StaticResource AlignmentConverter}}"
                              
                                 />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>

            </toolkit:Expander>


            <toolkit:Expander  x:Name="exDiagnosis" 
            HeaderTemplate="{StaticResource diagnosisHeader}" 
        Expanded="exDiagnosis_Expanded"
         Margin="0,5,0,0"
      
        >
                
                    <StackPanel>



                    <Button x:Name="btnDetailsDiagnosis" 
                Click="btnDetailsDiagnosis_Click" 
        Visibility="Collapsed"  
        Grid.Row="1"
         ContentTemplate="{StaticResource detailsDiagnosis}"
         HorizontalAlignment="Left"
       >

                    </Button>

                    <Grid Margin="0,3,0,3" x:Name="gridOutcomeTypes" Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="130"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock  Text="Outcome" Width="120"  FontWeight="Bold" Grid.Row="0" Grid.Column="0" />
                        
                        <input:AutoCompleteBox  Margin="2,0,0,2" 
                                    Grid.Row="0" Grid.Column="1"
                                    x:Name="acOutcomes"  
                                                FilterMode="Contains"
                                    ItemTemplate="{StaticResource detailsOutcome}"
                                    HorizontalAlignment="Left"
                        >
                            
                        </input:AutoCompleteBox>

                        <TextBlock Text="Attach" Grid.Row="1" Grid.Column="0" FontWeight="Bold" />

                        <CheckBox x:Name="chAttachOutcome" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left"/>

                    
                    
                    </Grid>


                    <ListBox x:Name="lbDiagnoses" 
        SelectionChanged="lbDiagnoses_SelectionChanged"
         >
                        <ListBox.Resources>
                            <LinearGradientBrush x:Key="DiagnosisBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FF000000" Offset="0"/>
                                <GradientStop Color="#FFCFCFFE" Offset="1"/>
                            </LinearGradientBrush>
                        </ListBox.Resources>
                        <!--<ListBox.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFCFCFFE" Offset="1"/>
                        <GradientStop Color="#FF7B7B7B" Offset="0.031"/>
                    </LinearGradientBrush>
                </ListBox.Background>-->
                        <ListBox.ItemTemplate>
                            <DataTemplate>

                                <TextBlock Text="{Binding Path=Concept}" 
                                ToolTipService.ToolTip="{Binding Path=Definition}" 
                                FontWeight="{Binding Converter={StaticResource MajorConverter}}"
                                Margin="{Binding Converter={StaticResource AlignmentConverter}}"
                                />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>

            </toolkit:Expander>


        </StackPanel>
    </ScrollViewer>

</UserControl>
